package com.example.controller;


import com.example.common.result.Result;
import com.example.entity.mes.Repair;
import com.example.service.RepairService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@CrossOrigin // 跨域
@RestController
@RequestMapping("/api/Repair")
@Api(tags = "维修单控制器")
public class RepairController {

    @Resource
    private RepairService repairService;

    @PostMapping("/queryRepairIPageList")
    @ResponseBody
    @ApiOperation("维修单分页查询")
    public Result queryRepairIPageList(@RequestParam(defaultValue = "1") Integer current, @RequestParam(defaultValue = "10") Integer size, @RequestBody Repair repair){
        return this.repairService.queryRepairIPageList(current,size,repair);
    }

    @GetMapping("/queryRepairById/{id}")
    @ResponseBody
    @ApiOperation("维修单通过id进行详细查询")
    public Result queryRepairById(@PathVariable Long id){
        return this.repairService.queryRepairById(id);
    }

    @PutMapping("/updateRepair")
    @ResponseBody
    @ApiOperation("维修单修改")
    public Result updateRepair(@RequestBody Repair repair){
        return this.repairService.updateRepair(repair);
    }

    @ApiOperation("维修单批量物理删除/也可单物理删除")
    @DeleteMapping("/deleteRepairBatch/{ids}")
    public Result deleteRepairBatch(@PathVariable List<Integer> ids) {
        return this.repairService.deleteRepairBatch(ids);
    }
}
